#pragma once
#include "PDTConst.h"
#include "PDTType.h"


class PDTConstSequence :  public PDTConst, public PDTSequence, public TraverseIfc <PDTConstSequence, PDTNode> {
    public:  TRAVERSAL_IFC_IMPL(PDTConstSequence)
private:
	vector <PDTNode *> * values;
public:
	PDTConstSequence(PDTCodeGraph & CG, PDTType * eType = NULL, vector <PDTNode *> * aValues = NULL) :
		PDTSequence(CG, "", eType), values(aValues) {
	}
	PDTConstSequence(PDTCodeGraph & CG, vector <PDTNode*> * aValues = NULL) :
		PDTSequence(CG, "", NULL), values(aValues) {

	}

	bool isConstSequence(){
		return true;
	}
    virtual bool isEqual (const PDTConst & rhs) const{
        if (!rhs.getNode()->isConstSequence())
            return false;
        PDTConstSequence & rhsCSeq = (PDTConstSequence&)rhs;

        if (getSize()!= rhsCSeq.getSize())
            return false;

        for(unsigned int i = 0; i < values->size(); i++) {
            PDTNode * v1 = values->at(i);
            PDTNode * v2 = rhsCSeq.getElementAt(i);
            PDTConst * c1 = (PDTConst * )v1;
            PDTConst * c2 = (PDTConst * )v2;
            if (!c1->isEqual(*c2))
                return false;
        }
        return true;
    };

	virtual unsigned int getSize() const {
        if (values == 0) return 0;
		return values->size();
	}

	virtual PDTNode* getNode() const {
		return (PDTNode*)this;
	}

	vector <PDTNode *> * getVector()
	{
		return values;
	}

	PDTNode * getElementAt(unsigned int i)
	{
		return values->at(i);
	}

	NodeTypeEnum getType() {
		return PDTSequenceConst_Em;
	}

	virtual PDTNode* clone(PDTCodeGraph& CG)
	{
		return this;
	}

	virtual stringstream & toString(stringstream& ss) const {
		ss << "{";
		if (values != NULL) {
			int size = values->size();
			for (int i = 0; i < size; i++) {
                if (i != 0) {
                    ss << ",";
                }
				PDTNode * node = values->at(i);
				node->toString(ss);
			}
		}
		ss << "}";
		return ss;
	}
};
